package com.ruizhong.centercontroll.util;

import android.os.Build;
import android.webkit.JavascriptInterface;

import com.ruizhong.centercontroll.MainActivity;

import wendu.dsbridge.CompletionHandler;


public class JsApi {

    private MainActivity mainActivity;

    public JsApi(MainActivity mainActivity) {
        this.mainActivity = mainActivity;
    }

    @JavascriptInterface
    public String testSyn(Object msg) {
        return msg + "[syn call]";
    }

    @JavascriptInterface
    public void testAsyn(Object msg, CompletionHandler handler) {
        handler.complete(msg + "[ asyn call]");
    }

    @JavascriptInterface
    public void getTokenId(Object tokenId) {
        MainActivity.tokenId = tokenId.toString();
    }

    @JavascriptInterface
    public void getAppData(Object data) {
        System.out.println(123);
        mainActivity.getAppData(data.toString());
    }

    @JavascriptInterface
    public void closeWindow(Object data){
        mainActivity.destoryVlcPlayers();
    }

}
